package activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.coolweather.lechat.R;

public class Register extends AppCompatActivity {
    private EditText reg_username,reg_password;
    private Button reg_button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        initView();
        reg_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String rusername= reg_username.getText().toString().trim();
                String rpassword = reg_password.getText().toString().trim();

                if (rusername.equals("")){
                    Toast.makeText(Register.this,"用户名不能为空",Toast.LENGTH_LONG).show();
                }else if (rpassword.equals("")){
                    Toast.makeText(Register.this,"密码不能为空",Toast.LENGTH_LONG).show();
                }else {

                    Intent intent  = new Intent(Register.this,login.class);
                    intent.putExtra("user",rusername);
                    intent.putExtra("pass",rpassword);
                    startActivity(intent);
                }
            }
        });
    }

    private void initView() {
        reg_username = findViewById(R.id.reg_username);
        reg_password = findViewById(R.id.reg_password);
        reg_button = findViewById(R.id.reg_button);
    }
}